package com.ruoyi.project.system.appsystext.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.appsystext.domain.AppSysText;
import com.ruoyi.project.system.appsystext.service.IAppSysTextService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 应用内容文本Controller
 * 
 * @author ruoyi
 * @date 2021-05-24
 */
@Controller
@RequestMapping("/system/appsystext")
public class AppSysTextController extends BaseController
{
    private String prefix = "system/appsystext";

    @Autowired
    private IAppSysTextService appSysTextService;

    @RequiresPermissions("system:appsystext:view")
    @GetMapping()
    public String appsystext()
    {
        return prefix + "/appsystext";
    }

    /**
     * 查询应用内容文本列表
     */
    @RequiresPermissions("system:appsystext:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AppSysText appSysText)
    {
        startPage();
        List<AppSysText> list = appSysTextService.selectAppSysTextList(appSysText);
        return getDataTable(list);
    }

    /**
     * 导出应用内容文本列表
     */
    @RequiresPermissions("system:appsystext:export")
    @Log(title = "应用内容文本", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AppSysText appSysText)
    {
        List<AppSysText> list = appSysTextService.selectAppSysTextList(appSysText);
        ExcelUtil<AppSysText> util = new ExcelUtil<AppSysText>(AppSysText.class);
        return util.exportExcel(list, "应用内容文本数据");
    }

    /**
     * 新增应用内容文本
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存应用内容文本
     */
    @RequiresPermissions("system:appsystext:add")
    @Log(title = "应用内容文本", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AppSysText appSysText)
    {
        return toAjax(appSysTextService.insertAppSysText(appSysText));
    }

    /**
     * 修改应用内容文本
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AppSysText appSysText = appSysTextService.selectAppSysTextById(id);
        mmap.put("appSysText", appSysText);
        return prefix + "/edit";
    }

    /**
     * 修改保存应用内容文本
     */
    @RequiresPermissions("system:appsystext:edit")
    @Log(title = "应用内容文本", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AppSysText appSysText)
    {
        return toAjax(appSysTextService.updateAppSysText(appSysText));
    }

    /**
     * 删除应用内容文本
     */
    @RequiresPermissions("system:appsystext:remove")
    @Log(title = "应用内容文本", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(appSysTextService.deleteAppSysTextByIds(ids));
    }
}
